<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- Diese Homepage wurde von Andreas Fendel erstellt. -->
<meta http-equiv="expires" content="0">
<meta name="author" content="Andreas Fendel">
<link rel="shortcut icon" href="images/boostedt.ico">
<meta name="Description" content="Tackmanncup - SV Boostedt">
<meta name="Keywords" content="SVB, svb, svb-liga, Boostedt, SV Boostedt, Tackmann, Cup, 2011, 2012, 2013, 2014, 2015, tackmanncup.de">
<meta name="robots" content="all">
<META NAME="Revisit" CONTENT="After 2 days">
<meta http-equiv="expires" content="0">
<title>Tackmanncup - SV Boostedt</title>
<link href="_css/default.css" rel="stylesheet" type="text/css" media="all" />
</head>

<body style="margin-left:10px; margin-top:10px; margin-right:10px;">

<?php
	$turnier=$_GET['turnier'];
	
	include('class_sql.php');
	$db = new Database();
	$db->connect();
	
	
	// Turnierdaten ermitteln
	$rows  = "*";
	$table = "ftv_turnier";
	$joins = "";
	$where = "ftv_turnier.id='".$turnier."'";
	$group = "";
	$order = "";
	
	$db->select($table, $rows, $where);
	$res_turnier = $db->getResult();
	$db->clear_results();
	
	// Vorrunden ermitteln
	$rows  = "*";
	$table = "ftv_gruppen";
	$joins = "";
	$where = "ftv_gruppen.turnier='".$turnier."' AND ftv_gruppen.art='2'";
	$group = "";
	$order = "";
	
	$db->select($table, $rows, $where);
	$res_vorrunden = $db->getResult();
	$db->clear_results();

	// Hauptrunden ermitteln
	$rows  = "*";
	$table = "ftv_gruppen";
	$joins = "";
	$where = "ftv_gruppen.turnier='".$turnier."' AND ftv_gruppen.art='1'";
	$group = "";
	$order = "";
	
	$db->select($table, $rows, $where);
	$res_hauptrunden = $db->getResult();
	$db->clear_results();

	// KO-Runden ermitteln
	$rows  = "*";
	$table = "ftv_gruppen";
	$joins = "";
	$where = "ftv_gruppen.turnier='".$turnier."' AND ftv_gruppen.art='0'";
	$group = "";
	$order = "";
	
	$db->select($table, $rows, $where);
	$res_korunden = $db->getResult();
	$db->clear_results();

	?>
    <table width="100%" border="0">
    	<tr><td rowspan="2" align="left"><img src="images/tackmann.jpg" width="100" /></td>
        <td align="center" class="head1">
        	<?php 
				echo $res_turnier['name']." ".$res_turnier['jahr'];
			?>
        </td>
        <td rowspan="2" align="right"><img src="images/tackmann.jpg" width="100" /></td>
        </tr>
    	<tr><td align="center" class="head2">
        	<?php 
				echo "<br>&Uuml;bersicht";
			?>
        </td></tr>
    	<tr><td colspan="3">
    	    <hr />
    <table border="0" width="100%">
    <colgroup>
    <?php
	foreach ($res_vorrunden as $value) {
		echo '<col width="';
		echo round(100/count($res_vorrunden), 0);
		echo '%>"';
	}
    ?>
	</colgroup>
        <tr>
<?php
foreach ($res_vorrunden as $value) {
	echo "<td align='center'>";
	echo "<div class='headline_text'>".$value['name']."</div>";
	
	$datumzeit=explode(' ', $value['datum']);
	$datum=explode('-', $datumzeit[0]);
	$zeit=explode(':', $datumzeit[1]);
	
	echo "<div style='font-weight:bold'><br>".$datum[2].".".$datum[1].".".$datum[0];
	echo "<br>ab ".$zeit[0].":".$zeit[1]." Uhr</div>";
	 
	// Teams laden
	//select($table, $rows = '*', $where = null, $order = null, $group = null, $joins = null)
	$rows  = "ftv_teams.id, ftv_teams.name, ftv_gruppeneinteilung.nummer";
	$table = "ftv_teams, ftv_gruppeneinteilung";
	$joins = "";
	$where = "ftv_teams.id=ftv_gruppeneinteilung.team AND ftv_gruppeneinteilung.gruppe='".$value['id']."'";
	$group = "";
	$order = "ftv_gruppeneinteilung.nummer ASC";

	$db->select($table, $rows, $where, $order, $group, $joins);
	$res_teams = $db->getResult();
	$db->clear_results();

	echo '<hr width="150">';
//	print_r($res_teams);
	foreach ($res_teams as $werte) {
		if($werte['nummer']<=$value['anzahl']) {
			echo $werte['name']."<br>";
		}
	}
	echo '<hr width="150"></td>';
}
?>
        </tr>
        </table>
    <hr />

        <table border="0" width="100%">
        <tr>
<?php
$count=0;
foreach ($res_hauptrunden as $value) {
	if ($count==1) {
        echo '<td rowspan="2" align="center"><img src="images/tackmann.jpg" width="100" /></td>';
		echo "<td align='center'>";
		echo "<div class='headline_text'>".$res_korunden['name']."</div>";
			
		$datumzeit=explode(' ', $res_korunden['datum']);
		$datum=explode('-', $datumzeit[0]);
		$zeit=explode(':', $datumzeit[1]);
			
		echo "<div style='font-weight:bold'><br>".$datum[2].".".$datum[1].".".$datum[0];
		echo "<br>ab ".$zeit[0].":".$zeit[1]." Uhr</div>";
			 
		// Teams laden
		//select($table, $rows = '*', $where = null, $order = null, $group = null, $joins = null)
		$rows  = "ftv_teams.id, ftv_teams.name, ftv_gruppeneinteilung.nummer";
		$table = "ftv_teams, ftv_gruppeneinteilung";
		$joins = "";
		$where = "ftv_teams.id=ftv_gruppeneinteilung.team AND ftv_gruppeneinteilung.gruppe='".$res_korunden['id']."'";
		$group = "";
		$order = "ftv_gruppeneinteilung.nummer ASC";
		
		$db->select($table, $rows, $where, $order, $group, $joins);
		$res_teams = $db->getResult();
		$db->clear_results();
		
		echo '<hr width="150">';
		//	print_r($res_teams);
		foreach ($res_teams as $werte) {
			if($werte['nummer']<=$res_korunden['anzahl']) {
				echo $werte['name']."<br>";
			}
		}
		echo '<hr width="150"></td>';
        echo '<td rowspan="2" align="center"><img src="images/tackmann.jpg" width="100" /></td>';
	}
	echo "<td align='center'>";
	echo "<div class='headline_text'>".$value['name']."</div>";
	
	$datumzeit=explode(' ', $value['datum']);
	$datum=explode('-', $datumzeit[0]);
	$zeit=explode(':', $datumzeit[1]);
	
	echo "<div style='font-weight:bold'><br>".$datum[2].".".$datum[1].".".$datum[0];
	echo "<br>ab ".$zeit[0].":".$zeit[1]." Uhr</div>";
	 
	// Teams laden
	$rows  = "ftv_teams.id, ftv_teams.name, ftv_gruppeneinteilung.nummer";
	$table = "ftv_teams, ftv_gruppeneinteilung";
	$joins = "";
	$where = "ftv_teams.id=ftv_gruppeneinteilung.team AND ftv_gruppeneinteilung.gruppe='".$value['id']."'";
	$group = "";
	$order = "ftv_gruppeneinteilung.nummer ASC";

	$db->select($table, $rows, $where, $order, $group, $joins);
	$res_teams = $db->getResult();
	$db->clear_results();

	echo '<hr width="150">';
//	print_r($res_teams);
	foreach ($res_teams as $werte) {
		if($werte['nummer']<=$value['anzahl']) {
			echo $werte['name']."<br>";
		}
	}
	echo '<hr width="150"></td>';
	$count++;
}
?>
        </tr>
        </table>
    <hr />
    </td></tr></table>
    
<?php 
	$db->disconnect();
?>
</body>
</html>
